<?php
namespace Wechat\Controller;

class WxAutoReplyController extends CommonController {
    
    public function add() {
        if (IS_POST) {
            $data = I('post.');
            $data['info']['customer_id'] = $this->customer_id;
            $res = empty($data['info']['id']) ? M('WxAutoReply')->add($data['info']) : M('WxAutoReply')->save($data['info']);
            $res === false ? $this->error('保存失败') : $this->success('保存成功');
        } else {
            $this->info['item'] = M('WxAutoReply')->where(array('customer_id'=>$this->customer_id, 'type'=>I('type')))->find();
            
            $this->assign($this->info);
            $this->display();
        }
    }
    
}
